package com.ujiuye;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 施立璇
 * @version 1.0
 * @description: TODO
 * @date 2021/6/6 20:50
 */
public class Demo01 {

    public static void main(String[] args) {

        ArrayList arrayList = new ArrayList();
        arrayList.add(-1);
        arrayList.add(-10);
        arrayList.add(-23);
        arrayList.add(-24);
        arrayList.add(5);
        arrayList.add(28);

        int i = get(arrayList);
        System.out.println(arrayList);
        System.out.println(i);
    }
    public static int get(List<Integer> list){
        int ii1 = 0;
        int ii2 = 0;
        int count = 0;
        int r = 0;
        for (int i = 0; i < list.size(); i++) {
            for (int j = i+1; j < list.size(); j++) {
                Integer i1 = list.get(i);
                Integer i2 = list.get(j);
                int i3 = i1+i2;
                int abs = Math.abs(i3);
                if (count == 0){
                     r = abs;
                 }else {
                     if (r > abs){
                         r = abs;
                          ii1 = list.get(i);
                          ii2 = list.get(j);
                     }
                 }
                 count++;
            }

        }
        System.out.println("原数1:======"+ii1+"原数2+======="+ii2);
        return r;
    }

}
